package io.xccit.controller;

import io.xccit.pojo.param.ProductCollectParam;
import io.xccit.result.AjaxResult;
import io.xccit.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author CH_ywx
 * @date 2023-09-15
 * @description
 */
@RestController
@RequestMapping("/product/collect")
public class ProductCollectController {

    @Autowired
    private IProductService productService;

    @PostMapping("/list")
    public AjaxResult getProductByIds(@RequestBody @Validated ProductCollectParam productCollectParam, BindingResult result){
        if (result.hasErrors()){
            return AjaxResult.build(201,"参数有误或没有收藏数据,请检查",null);
        }
        return productService.getProductByIds(productCollectParam.getProductIds());
    }
}
